﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TeamsPortal.Configuration;

namespace TeamsPortal.Web.Extensions
{
	public static class DateTimeExtensions
	{
		public static DateTime ToApplicationDateTime(this DateTime date)
		{
			if (date.Kind == DateTimeKind.Utc)
			{
                if (SiteConfiguration.Current.TimeZone != null)
				{
                    return TimeZoneInfo.ConvertTimeFromUtc(date, SiteConfiguration.Current.TimeZone);
				}
				else
				{
					return date.ToLocalTime();
				}
			}
			return date;
		}
	}
}
